home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG Disk (1990-09)(Memphis Amiga Group).zip / MAG Disk (1990-09)(Memphis Amiga Group).adf / sMOVIE / source / sMOVIEfreemem.c < prev    next >
C/C++ Source or Header  |  1989-12-29  |  2KB  |  83 lines

  1. /*    Tidies up after sMOVIE
  2.     Martin J. Round.    15-Oct-89
  3. */
  4.  
  5. #include "sMOVIE.h"
  6.  
  7. extern struct GfxBase *GfxBase;
  8. extern struct IntuitionBase *IntuitionBase;
  9. extern struct DosLibrary *DosBase;
  10. extern struct Library *DiskfontBase;
  11. extern struct TextFont *tf[MAXFONTS+1], *font, *defaultfont;
  12. extern struct View v;
  13. extern struct ViewPort vp;
  14. extern struct BitMap b;
  15. extern struct Window *window;
  16. extern char *txstart;
  17. extern int fonts,textsiz,cmdsiz,bitmapheight,maxwidth,maxdepth;
  18. extern short *cmdstart;
  19. extern BPTR _Backstdout;
  20.  
  21. void free_memory(level)
  22.  
  23. int level;  /*  indicates what to try and free  */
  24.  
  25. {
  26.     int i;
  27.  
  28.     switch (level) {
  29.         case 10:
  30.             for(i=0; i<maxdepth; i++)
  31.                 FreeRaster(b.Planes[i],maxwidth,bitmapheight);
  32.         case 9:
  33.               FreeColorMap(vp.ColorMap);
  34.         case 8:
  35.             FreeVPortCopLists(&vp);
  36.             FreeCprList(v.LOFCprList);
  37.             FreeCprList(v.SHFCprList);
  38.         case 7:
  39.             cmdsiz = rlsmem((char *)cmdstart,cmdsiz * sizeof(short));
  40.         case 6:
  41.             textsiz = rlsmem(txstart,textsiz);
  42.         case 5:
  43.             if (fonts) {
  44.                 for (i=fonts-1; i>=0; i--)
  45.                     if (tf[i])
  46.                         CloseFont(tf[i]);
  47.  
  48.                 CloseLibrary((struct Library *)DiskfontBase);
  49.                 }
  50.         case 4:
  51.             CloseFont(defaultfont);
  52.         case 3:
  53.             if (window) CloseWindow(window);
  54.             CloseLibrary((struct Library *)GfxBase);
  55.         case 2:
  56.             CloseLibrary((struct Library *)DosBase);
  57.         case 1:
  58.             CloseLibrary((struct Library *)IntuitionBase);
  59.  
  60.             break;
  61.  
  62.         }    /*  switch  */
  63.  
  64.     if (_Backstdout)  Close(_Backstdout);
  65.  
  66. }    /*  end of free_memory  */
  67.  
  68. void off_sprite() {        /*    kludge 'cos OFF_SPRITE won't work for me    */
  69.  
  70.     unsigned short *addr;
  71.  
  72.     addr = (unsigned short *) 0x0dff096;
  73.     *addr = 0x0020;
  74. }
  75.  
  76. void on_sprite() {        /*    kludge 'cos ON_SPRITE won't work for me        */
  77.  
  78.     unsigned short *addr;
  79.  
  80.     addr = (unsigned short *) 0x0dff096;
  81.     *addr = 0x8020;
  82. }
  83.